package com.neo.sk.util

/**
 * User: huangshanqi
 * Date: 2015/7/12
 * Time: 20:45
 */
object ParamsUtil {

  def getRetryTimeFromUrl(url:String):Int = {

    val retryPattern = "(.*)retry=(\\d+)(.*)".r
    val retryMatches = retryPattern.findFirstIn(url)
    if(retryMatches.isDefined){
      val retryPattern(_,retry,_) = url
      retry.toInt
    }else{
      1
    }
  }
  def getStartFromUrl(url:String):Int = {

    val startPattern = "(.*)start=(\\d+)(.*)".r
    val startMatches = startPattern.findFirstIn(url)
    if(startMatches.isDefined){
      val startPattern(_,start,_) = url
      start.toInt
    }else{
      1
    }
  }
}
